package com.mohan.bean;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

@Component
public class Car implements InitializingBean, DisposableBean {
    private String id;
    private String name;
    public Car(String id,String name){
        System.out.println("进来了全参构造函数");
        this.id = id;
        this.name = name;
    }

    public Car() {
        System.out.println("进来了无参构造");
    }

    public void init() {
        System.out.println("初始化啦！！！");
    }

    public void destory() {
        System.out.println("销毁啦！！");
    }

    public void setId(String id) {
        System.out.println("进来set了id");
        this.id = id;
    }

    public void setName(String name) {
        System.out.println("进来set了name");
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("进来了销毁的方法");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("进来了容器初始化的方法");
    }

    @Override
    public String toString() {
        return "Car{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                '}';
    }
}
